package com.polaris.live.adapter.chatPrice

import android.view.View
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.common.ext.convertArabicDigitsToNormal
import com.polaris.live.common.ext.toLevel
import com.polaris.live.databinding.AdapterChatPriceLevelBinding
import com.polaris.live.resp.back_resp.AppCallPriceBaseVo
import com.polaris.live.translation.R.string

/**
 * 聊天价格等级
 *
 * @author Created by 长空 on 2023/11/08/004 09:31
 */
class ChatLevelPriceAdapter :
    BaseBindingAdapter<AdapterChatPriceLevelBinding, AppCallPriceBaseVo>() {

    private var modifyLevel: Int = -1
    private var isDetail: Boolean = false

    override fun convert(
        holder: VBViewHolder<AdapterChatPriceLevelBinding>,
        item: AppCallPriceBaseVo
    ) {
        holder.vb.apply {
            tvLevel.text = context.getString(string.level_anchor, item.level.toLevel)
                .convertArabicDigitsToNormal()
            if (modifyLevel != -1 && item.level >= modifyLevel) {
                tvModified.visibility = View.VISIBLE
            } else {
                tvModified.visibility = View.GONE
            }
            if (isDetail) {
                tvDiamond.text = item.beans.toString()
                ivDiamond.visibility = View.GONE
                tvMin.visibility = View.GONE
            } else {
                tvDiamond.text = item.price.toString()
                ivDiamond.visibility = View.VISIBLE
                tvMin.visibility = View.VISIBLE
            }
        }
    }

    fun setModifyLevel(modifyLevel: Int) {
        this.modifyLevel = modifyLevel
    }

    fun setIsDetail(isDetail: Boolean) {
        this.isDetail = isDetail
    }

}